<%@ include file="/WEB-INF/jsp/include/head.jsp" %><%@ page language="java" pageEncoding="UTF-8"%>
<html>
<head>
	<%@ include file="/WEB-INF/jsp/include/title.jsp" %>
	<%@ include file="/WEB-INF/jsp/include/common_css.jsp" %>
	<%@ include file="/WEB-INF/jsp/include/common_script.jsp" %>	
	<script type="text/javascript">
	//<![CDATA[
	
	function serverMessage() {
		if("${serverMessage}" != "") {
			alert("${serverMessage}");
		}
	}

	function checkedAll() {
		if($("#checkedSid").attr("checked")) {
			$("input:checkbox:not(checked)").attr("checked", "checked");
		} else {
			$("input:checkbox:checked").attr("checked", "");
		}
	}

	function sharer() {
		$("#frmQuestion").attr("action", "sharer.html?currentPage=${param.currentPage}");
		$("#frmQuestion").submit();
	}
	
	$(document).ready(serverMessage);	
	//]]>
	</script>
</head>
<body>
	<%@ include file="/WEB-INF/jsp/include/top.jsp" %>
	<form:form id="frmQuestion" method="post" action="list.html">
	<div>
		<table width="100%">
			<tr>
				<td><input type="checkbox" id="checkedSid" name="checkedSid" value="0" onclick="javascript:checkedAll();" /></td>
				<td><spring:message code="question.question" /></td>
				<td><spring:message code="question.grade" /></td>
				<td><spring:message code="question.example" /></td>
				<td><spring:message code="question.patternCode" /></td>
				<td><spring:message code="question.hearingYn" /></td>
				<td><spring:message code="question.classification" /></td>
				<td><spring:message code="question.shareYn" /></td>
				<td><spring:message code="question.useYn" /></td>
				<td></td>
			</tr>
			<c:forEach items="${list}" var="question" varStatus="status">
			<tr>
				<td><input type="checkbox" name="sid" value="${question.sid}" /></td>
				<td><a href="<c:url value="/question/update.html?sid=${question.sid}"/>">${question.question}</a></td>
				<td><spring:message code="${question.grade}" /></td>
				<td>${question.example}</td>
				<td><spring:message code="${question.patternCode}" /></td>
				<td>${question.hearingYn}</td>
				<td><spring:message code="${question.classification}" /></td>
				<td>${question.shareYn}</td>
				<td>${question.useYn}</td>
				<td><a href="<c:url value="/question/remove.html?sid=${question.sid}&amp;patternCode=${question.patternCode}"/>">X</a></td>
			</tr>
			</c:forEach>
		</table>
		${pagination}
		<sec:authorize ifAnyGranted="ROLE_SUPER_USER, ROLE_ADMIN">
		<div id="rightButton">
			<a href="<c:url value="/category/list.html"/>"><spring:message code="button.sharer"/></a>
			<a href="#" onclick="javascript:sharer();"><spring:message code="button.sharer"/></a>
			<a href="<c:url value="/question/sharelist.html"/>"><spring:message code="button.sharer"/></a>
			<a href="<c:url value="/question/wizard.html"/>"><spring:message code="button.wizard"/></a>
			<a href="<c:url value="/question/add.html"/>"><spring:message code="button.add"/></a>
		</div>
		</sec:authorize>
	</div>
	</form:form>
	<%@ include file="/WEB-INF/jsp/include/footer.jsp" %>
</body>	
</html>